Skip to content

fix: add gen_ai common attributes to execute_event_loop_cycle spans#2067

Open
Zelys-DFKH wants to merge 1 commit intostrands-agents:mainfrom
Zelys-DFKH:fix/event-loop-cycle-span-common-attributes
Open

fix: add gen_ai common attributes to execute_event_loop_cycle spans#2067
Zelys-DFKH wants to merge 1 commit intostrands-agents:mainfrom
Zelys-DFKH:fix/event-loop-cycle-span-common-attributes

Conversation

@Zelys-DFKH
Copy link
Copy Markdown

Description

start_event_loop_cycle_span() initializes its attributes dict manually,
omitting the gen_ai.system / gen_ai.provider.name and gen_ai.operation.name
attributes produced by _get_common_attributes(). The four other span-start
methods (start_model_invoke_span, start_tool_call_span, start_agent_span,
start_multiagent_span) all call _get_common_attributes() first. This made
execute_event_loop_cycle spans inconsistent: they carry gen_ai.input.messages
(promoted by _add_event_messages()) but lack the identification attributes that
downstream OTEL tooling (collectors, exporters, redaction processors) relies on
for filtering.

The fix calls _get_common_attributes(operation_name="execute_event_loop_cycle")
at the start of start_event_loop_cycle_span(), consistent with the other span
methods.

Related Issues

Resolves #1876

Documentation PR

N/A

Type of Change

Bug fix

Testing

  • I ran hatch run prepare

Checklist

  • I have read the CONTRIBUTING document
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

start_event_loop_cycle_span() was initializing its attributes dict
manually, omitting the gen_ai.system/gen_ai.provider.name and
gen_ai.operation.name attributes produced by _get_common_attributes().
All other span start methods (start_model_invoke_span,
start_tool_call_span, start_agent_span, start_multiagent_span) call
_get_common_attributes() first. This made execute_event_loop_cycle
spans inconsistent and broke downstream OTEL tooling that filters on
these common identification attributes.

The fix calls _get_common_attributes(operation_name="execute_event_loop_cycle")
in start_event_loop_cycle_span(), consistent with the other span methods.

Resolves strands-agents#1876
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] execute_event_loop_cycle spans missing gen_ai.system/gen_ai.provider.name common attributes

1 participant